<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <f:loadBundle basename="com.Bundle" var="msg"/>
    <h:body>
        <f:view>
            <h:form>
                <h1><h:outputText value="#{msg.categories_datatable_header}"/></h1>
                <h:dataTable value="#{categoryBean.categories}" var="item" rendered="#{categoryBean.categories!= null}" 
                             rowClasses="firstRow,secondRow"
                             columnClasses=""
                             headerClass="tableHeader"
                             style="border-collapse:collapse;vertical-align:middle; text-decoration:none;margin-left:15px;">
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.categories_datatable_description}"/>
                        </f:facet>
                        <h:outputText value="#{item.categoryDescription}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.categories_datatable_name}"/>
                        </f:facet>
                        <h:commandLink action="#{categoryBean.edit(item.id)}">
                            <h:outputText value="#{item.name}"/></h:commandLink>
                    </h:column>
                    <f:facet name="footer">
                        <h:commandButton action="#{categoryBean.createNewCategory}" value="#{msg.new_button}"/>
                    </f:facet>
                </h:dataTable>


            </h:form>
            <!--<h:outputLink
                value="pages/category.jsf">
                <f:verbatim>Add New Category</f:verbatim>

        </h:outputLink>-->

            <h:panelGroup style="visibility: #{categoryBean.editMode ? 'visible':'hidden'};">
                <h:form>
                    <h:inputHidden id="id" value="#{categoryBean.category.id}"/>
                    <h1><h:outputText value="#{msg.edit_header}"/></h1>
                    <h:panelGrid columns="2">
                        <h:outputLabel value="#{msg.categories_datatable_description}" for="categoryDescription" />
                        <h:inputText id="categoryDescription" value="#{categoryBean.category.categoryDescription}" title="#{msg.categories_datatable_description}" />
                        <h:outputLabel value="#{msg.categories_datatable_name}" for="categoryName" />
                        <h:inputText id="categoryName" value="#{categoryBean.category.name}" title="CategoryName" />
                    </h:panelGrid>
                    <h:commandLink action="#{categoryBean.save}">save</h:commandLink>
                </h:form>
            </h:panelGroup>

        </f:view>

    </h:body>
</html>

